package com.sh.data.engine.domain.normalization.index.service;

import com.sh.data.engine.domain.base.model.PageResult;
import com.sh.data.engine.domain.dataasset.model.domain.TableInfoBizDomain;
import com.sh.data.engine.domain.normalization.index.model.domain.*;
import com.sh.data.engine.domain.normalization.index.model.param.IndexDevParam;
import com.sh.data.engine.domain.normalization.index.model.param.IndexListParam;
import com.sh.data.engine.domain.normalization.index.model.param.IndexParam;
import com.sh.data.engine.domain.normalization.index.model.param.PreviewDataParam;
import com.sh.data.engine.domain.normalization.research.dataowner.model.domain.DataOwnerDomain;
import com.sh.data.engine.domain.normalization.research.themedesign.model.domain.ThemeDomain;
import com.sh.data.engine.repository.dao.normalization.index.entity.IndexEntity;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author tinglan.ys
 * @description:
 * @date 2022/4/18 下午3:54
 */
public interface IndexMgtService {

    List<IndexCatalogDomain> listCatalog(Long projectId);

    List<IndexCatalogDomain> listCatalogWithTree(Long projectId);

    IndexCatalogDomain getIndexCatalogById(Long id);

    Boolean addCatalog(String name, Long projectId, Long pid);

    Boolean editCatalog(String name, Long id);

    Boolean delCatalog(Long id);

    Boolean addIndex(IndexParam indexParam);

    Boolean addIndexVersion(IndexParam indexParam);

    List<Long> getAllIndexCatalogByLevel(Long projectId, int level);

    List<Long> getAllChildIdByMultiPid(List<Long> pIds, Long projectId);

    /**
     * @description : 获取某个目录下所有的子
     * @author : tinglan.ys
     * @date : 2022/4/22
     */
    List<Long> getAllChildIdByPid(Long catalogId, Long projectId);

    PageResult<IndexDomain> indexList(IndexListParam indexListParam);

    /**
     * @description : 根据indexNum做了分组 返回Map
     * @author : tinglan.ys
     * @date : 2022/4/23
     */
    Map<Long, List<IndexDomain>> indexList2(
        String projectId,
        List<String> catalogIdList,
        String name,
        Short status,
        Integer pageNum,
        Integer pageSize);

    IndexDomain indexDetail(Long id);

    Boolean delIndex(Long id);

    List<TableInfoBizDomain> getTableList(Long projectId);

    void indexListExport(HttpServletResponse response, PreviewDataParam previewDataParam)
        throws IOException;

    Boolean saveIndexCorrelation(Long id, String tblName, Long tblId);

    Boolean updateByIdSelective(IndexEntity indexEntity);

    List<IndexBaseDomain> getIndexPublished(Long projectId, List<Long> dirList);

    List<AssociatedTaskDomain> getAssociatedTasks(String tableName, Long projectId);

    String alarmDisassociate(Long projectId, Long indexId);

    List<IndexForAbacusDomain> getIndexForAbacus(Long userId);

    List<QuotaDevSourceTableDomain> getDevSourceTable(Long projectId, Long themeId);

    List<QuotaDevSourceTableFieldDomain> getDevSourceTableField(Long projectId, Long tblId);

    void saveDev(IndexDevParam indexDevParam);

    IndexDomain getIndex(Long id);

    IndexDevParam getDev(Long projectId, Long id);

    List<String> getDevScriptFields(Long projectId, Long id);

    @Transactional(rollbackFor = Exception.class)
    void saveCdmIndex(IndexParam indexParam, Long userId);

    List<String> getFieldList(Long projectId, Long tblId);

    List<DataOwnerDomain> getDataOwnerByProjectId(Long projectId);

    List<ThemeDomain> getThemeList(Long projectId);

    void release(Long projectId, Long id);

    void down(Long projectId, Long id);
}
